import 'package:kepu/generated/json/base/json_convert_content.dart';
import 'package:kepu/model/Common_list_by_region_entity.dart';

CommonListByRegionEntity $CommonListByRegionEntityFromJson(
    Map<String, dynamic> json) {
  final CommonListByRegionEntity commonListByRegionEntity = CommonListByRegionEntity();
  final int? code = jsonConvert.convert<int>(json['code']);
  if (code != null) {
    commonListByRegionEntity.code = code;
  }
  final String? msg = jsonConvert.convert<String>(json['msg']);
  if (msg != null) {
    commonListByRegionEntity.msg = msg;
  }
  final List<CommonListByRegionData>? data = (json['data'] as List<dynamic>?)
      ?.map(
          (e) =>
      jsonConvert.convert<CommonListByRegionData>(e) as CommonListByRegionData)
      .toList();
  if (data != null) {
    commonListByRegionEntity.data = data;
  }
  return commonListByRegionEntity;
}

Map<String, dynamic> $CommonListByRegionEntityToJson(
    CommonListByRegionEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['code'] = entity.code;
  data['msg'] = entity.msg;
  data['data'] = entity.data.map((v) => v.toJson()).toList();
  return data;
}

extension CommonListByRegionEntityExtension on CommonListByRegionEntity {
  CommonListByRegionEntity copyWith({
    int? code,
    String? msg,
    List<CommonListByRegionData>? data,
  }) {
    return CommonListByRegionEntity()
      ..code = code ?? this.code
      ..msg = msg ?? this.msg
      ..data = data ?? this.data;
  }
}

CommonListByRegionData $CommonListByRegionDataFromJson(
    Map<String, dynamic> json) {
  final CommonListByRegionData commonListByRegionData = CommonListByRegionData();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    commonListByRegionData.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    commonListByRegionData.name = name;
  }
  final String? image = jsonConvert.convert<String>(json['image']);
  if (image != null) {
    commonListByRegionData.image = image;
  }
  final String? description = jsonConvert.convert<String>(json['description']);
  if (description != null) {
    commonListByRegionData.description = description;
  }
  final String? region = jsonConvert.convert<String>(json['region']);
  if (region != null) {
    commonListByRegionData.region = region;
  }
  final String? type = jsonConvert.convert<String>(json['type']);
  if (type != null) {
    commonListByRegionData.type = type;
  }
  final bool? plant = jsonConvert.convert<bool>(json['plant']);
  if (plant != null) {
    commonListByRegionData.plant = plant;
  }
  return commonListByRegionData;
}

Map<String, dynamic> $CommonListByRegionDataToJson(
    CommonListByRegionData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['image'] = entity.image;
  data['description'] = entity.description;
  data['region'] = entity.region;
  data['type'] = entity.type;
  data['plant'] = entity.plant;
  return data;
}

extension CommonListByRegionDataExtension on CommonListByRegionData {
  CommonListByRegionData copyWith({
    int? id,
    String? name,
    String? image,
    String? description,
    String? region,
    String? type,
    bool? plant,
  }) {
    return CommonListByRegionData()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..image = image ?? this.image
      ..description = description ?? this.description
      ..region = region ?? this.region
      ..type = type ?? this.type
      ..plant = plant ?? this.plant;
  }
}